package com.easykoo.web.tag;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

public class FormTag extends TagSupport {
    private String url;
    private String items;
    private int pageSize;
    private String imagePath;
    private String imageColor;
    private PageInfo pageInfo;


    public int doStartTag() throws JspException {

        this.pageInfo = (PageInfo) pageContext.getSession().getAttribute(items);
        if (pageInfo != null) {
            pageInfo.setPageSize(this.pageSize);
            if (BaseTag.isNotBlank(imagePath)) {
                pageInfo.setImageColor(imagePath);
            }
            if (BaseTag.isNotBlank(imageColor)) {
                pageInfo.setImageColor(imageColor);
            }
        }
        return EVAL_BODY_INCLUDE;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = ((HttpServletRequest) pageContext.getRequest()).getContextPath() + url;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public String getItems() {
        return items;
    }

    public void setItems(String items) {
        this.items = items;
    }

    public String getImagePath() {
        return imagePath;
    }

    public void setImagePath(String imagePath) {
        this.imagePath = imagePath;
    }

    public String getImageColor() {
        return imageColor;
    }

    public void setImageColor(String imageColor) {
        this.imageColor = imageColor;
    }

    public PageInfo getPageInfo() {
        return pageInfo;
    }

    public void setPageInfo(PageInfo pageInfo) {
        this.pageInfo = pageInfo;
    }
}